package com.example.unveil_the_leader.common;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
public class Result<T> {
    private String code;
    private String message;
    private T data;

    public static <T> Result<T> success(){
        Result<T> result = new Result<>();
        result.setCode(ResultCode.SUCCESS.code);
        result.setMessage(ResultCode.SUCCESS.message);
        return result;
    }

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>(data);
        result.setCode(ResultCode.SUCCESS.code);
        result.setMessage(ResultCode.SUCCESS.message);
        return result;
    }

    public static <T> Result<T> error(){
        Result<T> result = new Result<>();
        result.setCode(ResultCode.ERROR.code);
        result.setMessage(ResultCode.ERROR.message);
        return result;
    }

    public static <T> Result<T> error(String code, String message){
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    public Result(T data){this.data = data;}

    public Result(){}

}
